/**
 * Copyright © 2013 Creativor Studio.
 * About license information, please see LICENSE.txt.
 */
package org.creativor.rayson.client.transport;

import java.io.IOException;

import org.creativor.rayson.client.transport.nio.ClientNioConnection;
import org.creativor.rayson.client.transport.nio.NioListener;

/**
 * An wrapper object for {@link ClientNioConnection}.
 * 
 * @author creativor
 */
final class NioConnectionWrapper extends ClientNioConnection {

	private final HttpConnectionImpl httpConn;
	private final ConnectionPool pool;

	/**
	 * @param conn
	 * @param listener
	 */
	public NioConnectionWrapper(final HttpConnectionImpl httpConn,
			final ConnectionPool pool, final NioListener listener) {
		super(httpConn.getAgent().getAddress(), listener);
		this.httpConn = httpConn;
		this.pool = pool;
	}

	@Override
	public void close() throws IOException {
		super.close();
		this.pool.remove(this.httpConn);
	}

}
